package com.ctrip.study.refactor.simple;

import com.ctrip.study.refactor.simple.price.ChildrensPrice;
import com.ctrip.study.refactor.simple.price.NewReleasePrice;
import com.ctrip.study.refactor.simple.price.Price;
import com.ctrip.study.refactor.simple.price.RegularPrice;

/*
 * 影片
 */
public class Movie {

	public static final int CHILDRENS = 2;

	public static final int REGULAR = 0;

	public static final int NEW_RELEASE = 1;

	private String _title; // 名称

	private Price _price; // 价格（代号）

	public Movie(String title, int priceCode) {
		_title = title;
		setPriceCode(priceCode);
	}

	public int getPriceCode() {
		return _price.getPriceCode();
	}

	public void setPriceCode(int arg) {
		switch (arg) {
		case REGULAR:
			_price = new RegularPrice();
			break;
		case CHILDRENS:
			_price = new ChildrensPrice();
			break;
		case NEW_RELEASE:
			_price = new NewReleasePrice();
			break;
		default:
			throw new IllegalArgumentException("Incorrect Price Code");
		}
	}

	public String getTitle() {
		return _title;
	};

	public double getCharge(int daysRented) {
		return _price.getCharge(daysRented);
	}

	
	public int getFrequentRenterPoints(int daysRented) {
		return _price.getFrequentRenterPoints(daysRented);
	}

}
